<?php

declare(strict_types=1);

namespace App\Model;

use App\Model\Guild\GuildHost;
use Hyperf\DbConnection\Model\Model;

/**
 *  主播池-自己运营账户
 */
class HostPoolForNew extends Model
{
    protected $table = 'new_user_host_pool';
    protected $fillable = ['gender', 'user_id', 'flag'];

    static function getValidHosts()
    {
        return self::where(['flag' => 1])->pluck('user_id')->toArray();
    }

    static function insertGuildHosts($guildIds = [])
    {
        $hostIds = GuildHost::getHostIds($guildIds);
        foreach ($hostIds as $hostId => $time) {
            $ret = self::updateOrCreate(['user_id' => $hostId], [
                'user_id' => $hostId,
                'gender' => 0,
                'flag' => 1
            ]);
            echo "HostId:{$hostId}=={$ret}\n";
        }
    }
}
